# -*- coding: utf-8 -*-
from common import orm


class OrderWithdraw(orm.Model):
    __tablename__ = 'order_withdraw'

    id = orm.Column(orm.INTEGER, primary_key=True, autoincrement=True)
    mch_id = orm.Column(orm.INTEGER, nullable=False)
    mch_order_no = orm.Column(orm.VARCHAR(50), nullable=False, index=True)
    player_id = orm.Column(orm.VARCHAR(25), nullable=False)
    source_account_name = orm.Column(orm.VARCHAR(25), nullable=False)
    source_account_number = orm.Column(orm.VARCHAR(50), nullable=False)
    source_bank = orm.Column(orm.VARCHAR(25), nullable=False, server_default=orm.text("''"))
    source_card_code = orm.Column(orm.VARCHAR(10), nullable=False, server_default=orm.text("''"))
    account_name = orm.Column(orm.VARCHAR(25), nullable=False)
    account_number = orm.Column(orm.VARCHAR(50), nullable=False)
    bank = orm.Column(orm.VARCHAR(25), nullable=False, server_default=orm.text("''"))
    amount = orm.Column(orm.FLOAT(32, 2), nullable=False)
    exact_amount = orm.Column(orm.FLOAT(32, 2), nullable=False, server_default=orm.text("'0.00'"))
    fee = orm.Column(orm.FLOAT(18, 2), nullable=False, server_default=orm.text("'0.00'"))
    remarks = orm.Column(orm.VARCHAR(250), server_default=orm.text("''"))
    notes = orm.Column(orm.VARCHAR)
    status = orm.Column(orm.INTEGER, nullable=False, server_default=orm.text("'0'"))
    notify_url = orm.Column(orm.VARCHAR(100), nullable=False)
    mch_create_ip = orm.Column(orm.VARCHAR(16), nullable=False)
    sign = orm.Column(orm.VARCHAR(32), nullable=False)
    created_at = orm.Column(orm.DateTime, nullable=False, server_default=orm.text("CURRENT_TIMESTAMP"))
    operating_time = orm.Column(orm.DateTime)
    exact_time = orm.Column(orm.DateTime)
    updated_by = orm.Column(orm.VARCHAR(50))
    updated_at = orm.Column(orm.DateTime, server_default=orm.text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
    exe_locked = orm.Column(orm.Boolean, nullable=False, server_default=orm.text("'0'"))
    reassign_time = orm.Column(orm.DateTime)
    show_ukey = orm.Column(orm.Boolean, server_default=orm.text("'0'"))
    notified_at = orm.Column(orm.DateTime)
    notify_status = orm.Column(orm.INTEGER, nullable=False, server_default=orm.text("'0'"))
    notify_count = orm.Column(orm.INTEGER, nullable=False, server_default=orm.text("'0'"))
    order_type = orm.Column(orm.INTEGER, nullable=False, server_default=orm.text("'1'"))


class IssuingBank(orm.Model):
    __tablename__ = 'issuing_bank'

    id = orm.Column(orm.INTEGER, primary_key=True, autoincrement=True)
    source_bank = orm.Column(orm.VARCHAR, nullable=False, server_default=orm.text("''"))
    destination_bank = orm.Column(orm.VARCHAR, nullable=False, server_default=orm.text("''"))
    name = orm.Column(orm.VARCHAR, nullable=False, server_default=orm.text("''"))
    active = orm.Column(orm.INTEGER, nullable=False, server_default=orm.text("'0'"))


class OrderWithdrawReassign(orm.Model):
    __tablename__ = 'order_withdraw_reassign'

    id = orm.Column(orm.INTEGER, primary_key=True)
    order_id = orm.Column(orm.INTEGER, nullable=False)
    assign_at = orm.Column(orm.DateTime, nullable=False, server_default=orm.text("CURRENT_TIMESTAMP"))
    card_code_from = orm.Column(orm.VARCHAR(10), nullable=False)
    card_code_to = orm.Column(orm.VARCHAR(10), nullable=False)
